package ticketsell.gui;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;

import com.toedter.calendar.JCalendar;

public class PantallaCalendario extends JDialog{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JCalendar  selectorFechas;
	private JButton botonAceptar;
	private PanelPrincipal parent;
	private JButton botonCerrar;
	public PantallaCalendario(PanelPrincipal parent){
		this.parent = parent;
		this.setSize(600,600);
		selectorFechas = new JCalendar (new Date());
		selectorFechas.setSize(new Dimension(400,400));
		
		JPanel panelBotones = new JPanel();
		botonAceptar = new JButton("Aceptar");
		botonAceptar.addActionListener(new AceptarListener());
		botonAceptar.setSize(20,50);
		panelBotones.add(botonAceptar);
		
		botonCerrar = new JButton("Cerrar");
		botonCerrar.addActionListener(new CerrarListener());
		botonCerrar.setSize(20,20);
		panelBotones.add(botonCerrar);
		panelBotones.add(selectorFechas);
		
		this.add(panelBotones);
		}
	
	public void inicializar(){
		
	}
	
	public Date dameFecha(){
		return selectorFechas.getDate();		
	}
	
	 private class AceptarListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			parent.inicializarEvento(selectorFechas.getDate());
			dispose();
		}
	}
	 
	 private class CerrarListener implements ActionListener {
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		}
}
